<!DOCTYPE html>
<html lang="">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

  <link rel="icon" type="image/x-icon" href="./favicon.ico">
  <title>智医助手</title>
  <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

</head>

<body>
  <noscript>
    <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
        Please enable it to continue.</strong>
  </noscript>
  <div id="app"></div>
  <!-- built files will be auto injected -->

  <script>
    var auths = null, s, that = this;
    document.addEventListener("plusready", function () {

      // 扩展API加载完毕，现在可以正常调用扩展API

      plus.oauth.getServices(function (services) {

        // alert(1)
        auths = services;
        // alert(JSON.stringify(auths))
        console.log(JSON.stringify(auths));

      }, function (e) {

        alert("获取分享服务列表失败：" + e.message + " - " + e.code);

      });
      var webview = plus.webview.currentWebview();
      plus.key.addEventListener('backbutton', function () {
        webview.canBack(function (e) {
          if (e.canBack) {
            webview.back();
          } else {
            //webview.close(); //hide,quit
            //plus.runtime.quit();
            //首页返回键处理
            //处理逻辑：1秒内，连续两次按返回键，则退出应用；
            var first = null;
            plus.key.addEventListener('backbutton', function () {
              //首次按键，提示‘再按一次退出应用’
              if (!first) {
                first = new Date().getTime();
                console.log('再按一次退出应用');
                setTimeout(function () {
                  first = null;
                }, 1000);
              } else {
                if (new Date().getTime() - first < 1500) {
                  plus.runtime.quit();
                }
              }
            }, false);
          }
        })
      });
    }, false);


    var channel = null;
    var wxChannel = null; // 微信支付  
    // 1. 获取支付通道
    function plusReady() {
      // 获取支付通道
      plus.payment.getChannels(function (channels) {
        console.log(11111111111);
        console.log(channels);
        console.log(JSON.stringify(channels));
        for (var i in channels) {
          if (channels[i].id == "wxpay") {
            wxChannel = channels[i];
          }
        }
      }, function (e) {
        that.toast("获取支付通道失败：" + e.message);
      });
    }
    document.addEventListener('plusready', plusReady, false);

  </script>
</body>


</html>